import { createRouter, createWebHistory } from "vue-router"
import { routes } from "./commonRoutes"
import {$Storage} from "@utils/storage.js"


const router = createRouter({
  history: createWebHistory(),
  routes,
})



router.beforeEach((to, from,next) => {
  if(!$Storage.getItem("jwttoken")){
    next("/login")
    return false
  }else{
    next()
  }
})

export const setUpRouter = (app) => {
  app.use(router)
}

export default router